package com.fengxu.springclouod.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
*@Description gateway的配置类
*@Author 风珝
*@Date 2021/1/17 8:30
*@Version 1.0.0
*/
@Configuration
public class GatewayConfig {


    // 配置路由
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder){
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        // 映射 /guonei -> https://news.baidu.com/guonei
        routes.route("route_path3", r -> r.path("/guonei")
                        .uri("https://news.baidu.com/guonei")
                    );

        return routes.build();
    }
}
